<?php

class Chatbox extends action
{
	public function __construct()
	{
		if ($this->getInput('action') == null)
			return;
		
		// Does this action exist?
		if (file_exists(path . "inc/actions/" . $this->getInput('action') . ".php"))
		{
			$this->updateUserTime();
			
			require(path . "inc/actions/" . $this->getInput('action'). ".php");
			
			if (isset($_))
			{
				$action = new $_();
				$action->execute($this);
				
			} // end if
			else
			{
				$this->finish();
				
			} // end else
			
		} // end if
		else
		{
			$this->finish();
			
		} // end else
		
	} // end function
	
	public function updateUserTime()
	{
		$uM = $this->getModel('user');
		$uM->setUser(-1);
		$uM->setLastTime();
		
	} // end fuction
	
	public function getModel($m)
	{
		if (file_exists(path . "inc/models/" . $m . ".php"))
		{
			require_once(path . "inc/models/" . $m . ".php");
			
			if (isset($_))
				$this->setModelCls($m, $_);
			else
				$_ = $this->getModelCls($m);
			
			return (new $_());
			
		} // end if
		else
			return $this->getModelCls($m);
		
	} // end function
	
} // end class

new Chatbox();

?>